import request from '@/utils/request';
import { other } from './prefix';

// 作品
const specialWorksManage = {
  // 创建视频
  createWorks(params) {
    return request.post(other + '/special_work', params);
  },
  // 查询视频列表
  getWorks(params) {
    return request.get(other + '/special_work', { params });
  },
  // 上传视频封面
  uploadWorks(id, data) {
    return request.post(other + '/special_work/' + id + '?op=upload_file&name=title_page', data);
  },
  // 更新视频
  updWorks(id, data) {
    return request.post(other + '/special_work/' + id, data);
  },
  // 删除视频
  delWorks(id) {
    return request.delete(other + '/special_work/' + id);
  },
};

// 视频
const specialVideosManage = {
  // 创建视频
  createVideos(params) {
    return request.post(other + '/special_video', params);
  },
  // 查询视频列表
  getVideos(params) {
    return request.get(other + '/special_video', { params });
  },
  // 上传视频封面
  uploadVideos(id, data) {
    return request.post(other + '/special_video/' + id + '?op=upload_file&name=title_page', data);
  },
  // 上传视频
  uploadVideosVideo(id, data) {
    return request.post(other + '/special_video/' + id + '?op=upload_file&name=url', data);
  },
  // 更新视频
  updVideos(id, data) {
    return request.post(other + '/special_video/' + id, data);
  },
  // 删除视频
  delVideos(id) {
    return request.delete(other + '/special_video/' + id);
  },
};

// 锦集
const specialCollectionsManage = {
  // 创建锦集
  createCollections(params) {
    return request.post(other + '/special_collection', params);
  },
  // 查询锦集列表
  getCollections(params) {
    return request.get(other + '/special_collection', { params });
  },
  // 上传锦集图片
  uploadCollections(id, data) {
    return request.post(other + '/special_collection/' + id + '?op=upload_file&name=url', data);
  },
  // 更新锦集
  updCollections(id, data) {
    return request.post(other + '/special_collection/' + id, data);
  },
  // 删除锦集
  delCollections(id) {
    return request.delete(other + '/special_collection/' + id);
  },
};

// 文章
const specialEssaysManage = {
  // 创建专题文章
  createEssays(params) {
    return request.post(other + '/special_essay', params);
  },
  // 查询专题文章列表
  getEssays(params) {
    return request.get(other + '/special_essay', { params });
  },
  // 查询专题文章详情
  getEssaysDetails(id) {
    return request.get(other + '/special_essay/' + id);
  },
  // 更新专题文章
  updEssays(id, data) {
    return request.post(other + '/special_essay/' + id, data);
  },
  // 删除专题文章
  delEssays(id) {
    return request.delete(other + '/special_essay/' + id);
  },
};

const specialSubManage = {
  // 查询专题列表
  getSpecialSub(params) {
    return request.get(other + '/special_sub', { params });
  },
  // 创建专题
  setSpecialSub(params) {
    return request.post(other + '/special_sub', params);
  },
  // 更新专题
  updSpecialSub(id, params) {
    return request.post(other + '/special_sub/' + id, params);
  },
  // 删除专题
  delSpecialSub(id) {
    return request.delete(other + '/special_sub/' + id);
  },
  // 根据专题id获取活动集锦
  getPictureList(id, params) {
    return request.get(other + '/special_sub/' + id + '?op=picture_list', { params });
  },
  // 根据专题id获取活动集锦
  getVideoList(id, params) {
    return request.get(other + '/special_sub/' + id + '?op=video_list', { params });
  },
  // 根据专题id获取相关文章列表
  getEssayList(id, params) {
    return request.get(other + '/special_sub/' + id + '?op=essay_list', { params });
  },
  // 根据专题id获取相关作品列表
  getWorkList(id, params) {
    return request.get(other + '/special_sub/' + id + '?op=work_list', { params });
  },
  // 移动专题活动列表
  moveSpecialSub(id, type) {
    return request.post(other + '/special_sub/' + id + '?op=' + type, {});
  },
  ...specialEssaysManage,
  ...specialCollectionsManage,
  ...specialVideosManage,
  ...specialWorksManage,
};

export default specialSubManage;
